<?php

class stTwitterToolboxHook extends sthook_2_1 {

    public function hookCustom() {
        $method = array($this, 'showStplugin');
        add_shortcode('ShowStplugin', $method);

//        $method = array($this, 'custom_field_create');
//        add_action('admin_menu', $method);
//        $method = array($this, 'custom_field_handle');
//        add_action('edit_post', $method);

//        $method = array($this, 'hook1');
//        add_filter('query_string', $method, 100, 1);
    }

    public function includeExtraPlugin() {
        // default process here        
    }

    //Initialize hook function

    /**
     * Sample short code
     *
     * Create a short code to show stplugin every where
     *
     * @since Plugin expert 1.0
     */
    function showStplugin($args) {
        $args = shortcode_atts(array(
                    'stplugin_id' => '0'
                        ), $args);

        $controllerName = $this->config['plugin_name'] . "Controller";
        $controllerObject = new $controllerName($this->config);
        return $controllerObject->getAction('showStplugin', $args);
    }

    public function custom_field_create() {
        if (function_exists('add_meta_box')) {
            $controllerName = $this->config['plugin_name'] . "Controller";
            $controllerObject = new $controllerName($this->config);
            $controllerObject->actionName = 'custom_field';

            $method = array($controllerObject, 'getAction');
            add_meta_box('custom_field', 'Custom field', $method, 'post', 'normal');
            add_meta_box('custom_field', 'Custom field', $method, 'page', 'normal');
        }
    }

    public function custom_field_handle() {
//        $this->save_attach_file();
//        $this->save_attach_thumb_file();
        if (isset($_POST['post_ID']))
            $pID = $_POST['post_ID'];
        if (isset($_POST['action']) && $_POST['action'] == 'editpost') {
            if (isset($_POST['demo_link'])) {
                $demo_link = $_POST['demo_link'];
                update_post_meta($pID, 'demo_link', $demo_link);
            }
            if (isset($_POST['expert_description'])) {
                $expert_description = $_POST['expert_description'];
                update_post_meta($pID, 'expert_description', $expert_description);
            }
        }
    }

    public function hook1($query_string){
        //var_dump($query_string);
        $current_page = 'pamelding';
        $query_string = 'pagename='.$current_page;
        $cat_name = 'cat1';
        $view = 'category';
        
        return $query_string;
    }
}

?>